/**
 * 
 */
package com.csair.youth.business.query.impl;

import java.util.Date;

import com.csair.youth.constant.Constant;
import com.csair.youth.database.Resource;

/**
 * @author mickey
 *
 */
public class ResourceQueryEntryImpl extends BaseQueryEntryImpl {

	/* (non-Javadoc)
	 * @see com.csair.youth.business.query.impl.BaseQueryEntryImpl#cast(java.lang.Object)
	 */
	@Override
	protected Object cast(Object obj) {
		if(obj == null) return null;
		Object xx[] = (Object [])obj;
		Resource item = new Resource();
		item.setId((String)xx[0]);
		item.setFileName((String)xx[1]);
		item.setCategoryName((String)xx[2]);
		item.setUploadUserName((String)xx[3]);
		item.setUploadIp((String)xx[4]);
		item.setAuditResult(getAuditResultByCode((String)xx[5]));
		item.setDownloadTimes((Integer)xx[6]);
		item.setUploadTime((Date)xx[7]);
		return item;
	}

	private String getAuditResultByCode(String code){
		if(code == null || code.equals(Constant.RESOURCE_AUDIT_WAIT)) return "待审核";
		else if(code.equals(Constant.RESOURCE_AUDIT_ING)) return "审核中";
		else if(code.equals(Constant.RESOURCE_AUDIT_PASS)) return "审核通过";
		else return "审核不通过";
	}
}
